#include <iostream>
#include <vector>
#include <cstring>
#include <bitset>
#include <algorithm>
using namespace std;

// 将字符串按给定字符串总的字符分割之后的元素存入数列
vector<string> split(const string& str, const string& delim) {  
	vector<string> res;  
	if("" == str) return res;  
	//先将要切割的字符串从string类型转换为char*类型  
	char * strs = new char[str.length() + 1];
	strcpy(strs, str.c_str());   
 
	char * d = new char[delim.length() + 1];  
	strcpy(d, delim.c_str());  
 
	char *p = strtok(strs, d);  
	while(p) {  
		string s = p; //分割得到的字符串转换为string类型  
		res.push_back(s); //存入结果数组  
		p = strtok(NULL, d);  
	}  
 
	return res;  
}

void print_subset(vector<vector<string> > vec)
{   // 用以输出子集
        for (int i = 0; i < vec.size(); i++)
        {
            cout<<"{";
            for (int j = 0; j < vec[i].size(); j++)
            {
                if(j != vec[i].size() - 1) cout<<vec[i][j]<<",";
                else cout<<vec[i][j];
            }
            cout<<"}"<<endl;
        }
}

int main()
{
    // 读入集合并分隔元素存入vector
    string str;
    cin>>str;
    vector<string> set = split(str, "{,}");
    reverse(set.begin(),set.end());  // 逆序排序方便后续处理
    for (int i = 0; i <= set.size(); i++)
    {   // 多少个元素的子集
        vector<int> choice(set.size(), 0);  // 选择数组, 初始化全为0
        for(int j = 0;j < i;++j)
        {   // 初始化待取元素个数的数组, 即该数组中共有i个1
            choice[choice.size() - 1 - j] = 1;
        }
        
        vector<vector<string> > subset;   // 最终结果存入此字符串数组
        do
        {   // 遍历所有可能
            vector<string> s;
            for (int j = choice.size() - 1; j >= 0; --j)
            {
                if(choice[j] != 0) s.push_back(set[j]);
            }
            subset.push_back(s);     //写入结果
        } while (next_permutation(choice.begin(),choice.end()));
        sort(subset.begin(), subset.end());   // 将结果按字典序排列
        print_subset(subset);
    }    
    return 0;
}
